<style include="common">
  :host {
    flex-grow: 1;
  }
  #container {
    display: grid;
    grid-template-areas:
      '. . content . .';
    grid-template-columns: 1fr 16px minmax(568px, 920px) 16px 1fr;
    grid-template-rows: minmax(0, 1fr);
    height: 100%;
    margin-block-end: 48px;
  }
  :host-context(body.jelly-enabled) #container {
    grid-template-areas:
      '. leftspacertop    preview rightspacertop    .'
      '. leftspacerbottom content rightspacerbottom .';
    grid-template-columns: 1fr 16px minmax(568px, 920px) 16px 1fr;
    grid-template-rows: auto minmax(0, 1fr);
    margin-block-end: 0;
  }
  #mainSettings {
    display: flex;
    flex-direction: column;
    grid-area: content;
  }
  toggle-row,
  #toggleRowPlaceholder {
    margin: 0 8px;
  }
  .ambient-toggle-label-placeholder {
    height: 20px;
    margin-bottom: 2px;
    width: 10%;
  }
  /* TODO(b/253470553): Remove after Ambient subpage UI change is released. */
  ambient-preview-small.jelly-disabled {
    margin: 20px 8px 0 8px;
  }
  ambient-preview-small {
    grid-area: preview;
    margin: 0 8px;
  }
  albums-subpage {
    grid-area: content;
  }
  :host-context(body.jelly-enabled) albums-subpage,
  #mainSettings {
    background-color: var(--cros-bg-color);
    padding: 20px 0 24px 0;
  }
  .animation-placeholder-list {
    width: 516px;
  }
  .animation-placeholder-container {
    box-sizing: border-box;
    overflow: hidden;
    padding: calc(var(--personalization-app-grid-item-spacing) / 2);
    /* Subtract 0.34px to fix subpixel rounding issues with iron-list. This
     * ensures all grid items in a row add up to at least 1px smaller than the
     * parent width. */
    width: calc(100% / 3 - 0.34px);
  }
  .animation-item-placeholder {
    align-items: center;
    border-radius: var(--personalization-app-grid-item-border-radius);
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    height: 120px;
    justify-content: center;
    overflow: hidden;
    position: relative;
    width: 100%;
  }
  .animation-item-title-placeholder {
    margin-top: 8px;
  }
  div[class^='ambient-text-placeholder'] {
    align-items: flex-start;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow: hidden;
    padding-inline: var(--cr-section-padding) var(--cr-icon-ripple-padding);
    width: 100%;
  }
  #topicSourceTextPlaceholder {
    height: 64px;
  }
  #weatherUnitTextPlaceholder {
    height: 48px;
  }
  .ambient-text-placeholder-0 {
    border-bottom: 1px solid var(--cros-separator-color);
  }
  div[class^='ambient-text-placeholder'] > * + * {
    margin-top: 8px;
  }
  .ambient-primary-text-placeholder {
    height: 20px;
    width: 75%;
  }
  .ambient-secondary-text-placeholder {
    height: 20px;
    width: 50%;
  }
</style>
<div id="container">
  <template is="dom-if" if="[[isPersonalizationJellyEnabled_]]">
    <div class="leftspacertop"></div>
    <div class="leftspacerbottom"></div>
    <ambient-preview-small></ambient-preview-small>
    <!-- restamp to avoid layout issues with iron-list resizing while hidden -->
    <template is="dom-if" if="[[shouldShowMainSettings_(path)]]" restamp>
      <div id="mainSettings">
        <template is="dom-if" if="[[loading_]]">
          <div id="toggleRowPlaceholder">
            <div class="ambient-toggle-label-placeholder placeholder"></div>
            <div class="ambient-toggle-row-container">
              <div class="ambient-toggle-row">
                <div class="ambient-primary-text-placeholder placeholder"></div>
              </div>
            </div>
          </div>
          <div id="animationThemePlaceholder">
            <h3 id="animationTitle" class="ambient-subpage-element-title" aria-hidden="true">
              $i18n{ambientModeAnimationTitle}
            </h3>
            <iron-list class="animation-placeholder-list" items="[[getPlaceholders_(3)]]" grid>
              <template>
                <div class="animation-placeholder-container">
                  <div class="animation-item-placeholder placeholder"></div>
                  <div class="animation-item-title-placeholder
                      ambient-primary-text-placeholder placeholder"></div>
                </div>
              </template>
            </iron-list>
          </div>
          <div id="topicSourcePlaceholder">
            <h3 id="topicSourceTitle" class="ambient-subpage-element-title" aria-hidden="true">
              $i18n{ambientModeTopicSourceTitle}
            </h3>
            <iron-list items="[[getPlaceholders_(2)]]" grid>
              <template>
                  <div id="topicSourceTextPlaceholder" class$="{{getClassContainer_(index)}}">
                    <div class="ambient-primary-text-placeholder placeholder"></div>
                    <div class="ambient-secondary-text-placeholder placeholder"></div>
                  </div>
              </template>
            </iron-list>
          </div>
          <div id="weatherUnitPlaceholder">
            <h3 id="weatherTitle" class="ambient-subpage-element-title" aria-hidden="true">
              $i18n{ambientModeWeatherTitle}
            </h3>
            <iron-list items="[[getPlaceholders_(2)]]" grid>
              <template>
                <div id="weatherUnitTextPlaceholder" class$="{{getClassContainer_(index)}}">
                  <div class="ambient-secondary-text-placeholder placeholder"></div>
                </div>
              </template>
            </iron-list>
          </div>
        </template>
        <template is="dom-if" if="[[!loading_]]">
          <toggle-row id="ambientToggleRow" checked="[[ambientModeEnabled_]]"
              on-click="onClickAmbientModeButton_" on-change="onToggleStateChanged_">
          </toggle-row>
          <template is="dom-if" if="[[ambientModeEnabled_]]">
            <animation-theme-list
                selected-animation-theme="[[animationTheme_]]">
            </animation-theme-list>
            <topic-source-list selected-topic-source="[[topicSource_]]"
                selected-animation-theme="[[animationTheme_]]"
                has-google-photos-albums="[[hasGooglePhotosAlbums_(albums_)]]">
            </topic-source-list>
            <ambient-weather-unit
                selected-temperature-unit="[[temperatureUnitToString_(temperatureUnit_)]]">
            </ambient-weather-unit>
            <template is="dom-if" if="[[isScreenSaverDurationEnabled_]]">
              <duration-list duration="[[duration_]]">
              </duration-list>
            </template>
          </template>
        </template>
      </div>
    </template>
    <template is="dom-if" if="[[shouldShowAlbums_(path)]]" restamp>
      <albums-subpage topic-source="[[getTopicSource_(queryParams)]]"
          albums="[[getAlbums_(albums_, queryParams)]]">
      </albums-subpage>
    </template>
    <div class="rightspacertop"></div>
    <div class="rightspacerbottom"></div>
  </template>
  <template is="dom-if" if="[[!isPersonalizationJellyEnabled_]]">
    <!-- restamp to avoid layout issues with iron-list resizing while hidden -->
    <template is="dom-if" if="[[shouldShowMainSettings_(path)]]" restamp>
      <div id="mainSettings">
        <template is="dom-if" if="[[loading_]]">
          <div id="toggleRowPlaceholder" class="ambient-toggle-row-container">
            <div class="ambient-toggle-row">
              <div class="ambient-primary-text-placeholder placeholder"></div>
            </div>
          </div>
          <ambient-preview-small class="jelly-disabled"></ambient-preview-small>
          <div id="animationThemePlaceholder">
            <h3 id="animationTitle" class="ambient-subpage-element-title" aria-hidden="true">
              $i18n{ambientModeAnimationTitle}
            </h3>
            <iron-list class="animation-placeholder-list" items="[[getPlaceholders_(3)]]" grid>
              <template>
                <div class="animation-placeholder-container">
                  <div class="animation-item-placeholder placeholder"></div>
                  <div class="animation-item-title-placeholder
                      ambient-primary-text-placeholder placeholder"></div>
                </div>
              </template>
            </iron-list>
          </div>
          <div id="topicSourcePlaceholder">
            <h3 id="topicSourceTitle" class="ambient-subpage-element-title" aria-hidden="true">
              $i18n{ambientModeTopicSourceTitle}
            </h3>
            <iron-list items="[[getPlaceholders_(2)]]" grid>
              <template>
                  <div id="topicSourceTextPlaceholder" class$="{{getClassContainer_(index)}}">
                    <div class="ambient-primary-text-placeholder placeholder"></div>
                    <div class="ambient-secondary-text-placeholder placeholder"></div>
                  </div>
              </template>
            </iron-list>
          </div>
          <div id="weatherUnitPlaceholder">
            <h3 id="weatherTitle" class="ambient-subpage-element-title" aria-hidden="true">
              $i18n{ambientModeWeatherTitle}
            </h3>
            <iron-list items="[[getPlaceholders_(2)]]" grid>
              <template>
                <div id="weatherUnitTextPlaceholder" class$="{{getClassContainer_(index)}}">
                  <div class="ambient-secondary-text-placeholder placeholder"></div>
                </div>
              </template>
            </iron-list>
          </div>
        </template>
        <template is="dom-if" if="[[!loading_]]">
          <toggle-row id="ambientToggleRow" class="clickable" checked="[[ambientModeEnabled_]]"
              on-click="onClickAmbientModeButton_" on-change="onToggleStateChanged_">
          </toggle-row>
          <template is="dom-if" if="[[!ambientModeEnabled_]]">
            <ambient-zero-state id="zeroState"></ambient-zero-state>
          </template>
          <template is="dom-if" if="[[ambientModeEnabled_]]">
            <ambient-preview-small class="jelly-disabled"></ambient-preview-small>
            <animation-theme-list
                selected-animation-theme="[[animationTheme_]]">
            </animation-theme-list>
            <topic-source-list selected-topic-source="[[topicSource_]]"
                selected-animation-theme="[[animationTheme_]]"
                has-google-photos-albums="[[hasGooglePhotosAlbums_(albums_)]]">
            </topic-source-list>
            <ambient-weather-unit
                selected-temperature-unit="[[temperatureUnitToString_(temperatureUnit_)]]">
            </ambient-weather-unit>
          </template>
        </template>
      </div>
    </template>
    <!-- restamp to avoid layout issues with iron-list resizing while hidden -->
    <template is="dom-if" if="[[shouldShowAlbums_(path)]]" restamp>
      <albums-subpage topic-source="[[getTopicSource_(queryParams)]]"
          albums="[[getAlbums_(albums_, queryParams)]]">
      </albums-subpage>
    </template>
  </template>
</div>
